package org.example;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.util.Arrays;

@Mojo(name = "MyPlugin")
public class MyPlugin extends AbstractMojo {

    @Parameter(property = "username", defaultValue = "ccc")
    private String userName;

    @Parameter(property = "age", defaultValue = "33")
    private int age;

    @Parameter(property = "flag")
    private boolean flag;

    @Parameter(property = "myArr")
    // @Parameter建议指定property属性，否则通过命令传递参数的时候无法识别命令中的参数
    private String[] myArr;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        System.out.println("MyPlugin execute=========== userName =" + userName + " age = " + age + " flag = " + flag);
        System.out.println("myArr = " + Arrays.toString(myArr));
    }
}
